import request from '@/utils/request'

export function dbaseTable(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/table`,
    method: 'post',
    data: query
  })
}

export function dbaseSelectData(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/select`,
    method: 'post',
    data: query
  })
}

export function dbaseTableData(dbKey, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/${dbKey}/table`,
    method: 'post',
    data: query
  })
}

export function dbaseTableSelectData(dbKey, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/${dbKey}/select`,
    method: 'post',
    data: query
  })
}

export function dbaseLoad(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/load`,
    method: 'get',
    params: query
  })
}

export function dbaseSave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/save`,
    method: 'post',
    data: query
  })
}

export function dbaseExecute(executorId, query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/execute/${executorId}`,
    method: 'post',
    data: query
  })
}

export function dbaseCancel(executorId) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/cancel/${executorId}`,
    method: 'post'
  })
}

export function dbaseDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/delete`,
    method: 'post',
    data: query
  })
}

export function dbaseExport(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/exportQuery`,
    method: 'post',
    data: query
  })
}

// 获取所有数据库
export function getDataBase(dbKey) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/dbInfo`,
    method: 'post',
    data: {
      dbKey: dbKey
    }
  })
}

export function customQuerySelectData(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/query/select`,
    method: 'post',
    data: query
  })
}

export function customQueryLoad(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/query/load`,
    method: 'get',
    params: query
  })
}

export function customQuerySave(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/query/save`,
    method: 'post',
    data: query
  })
}

export function customQueryDelete(query) {
  return request({
    url: `${process.env.VUE_APP_MODULE_ADMIN_API}/api/system/dbase/query/delete`,
    method: 'post',
    data: query
  })
}
